<?php
class hamilton_k_officeStaffList extends ss_konstrukt_master_component {
	protected $templates;
	protected $structureMapper;
	protected $entryMapper;
	protected $strucure;
	protected $node;
	protected $staff;
	protected $office;
	
	public function __construct($ss_settings,hamilton_templatefactory $templates, hamilton_dao_structure_mapper $structureMapper){
		$this->structureMapper=$structureMapper;
		$this->structure=$structureMapper->getFullActiveStructure();
    	$this->templates = $templates;
		$this->settings=$ss_settings;
	}
	
	public function dispatch(){
		$this->office= $this->context->office();
		$this->staff=$this->injector()->create('hamilton_dao_staff_mapper')->staffByOffice($this->office->primary());
		//$this->node=$this->structure->getNodeFromSlug($this->name());
		//$this->document->setTitle("Structure ".$this->node->headline());
		ss_error::log('Office staff list dispatch');
		//$this->entries=$this->entryMapper->getEntriesByCategorySlug($this->name());
		//ss_error::log($this->node->primary(),'ID');
		return parent::dispatch();
	}
  
	protected function map($name){
		return 'hamilton_k_staff';
		//if($this->structure->levelHasSlug($this->level(),$name)) return 'hamilton_k_structure';
	}
	
	protected function renderHtml() {
		$content=array();
		foreach($this->staff as $obj){
			$content[]=$obj->getMasterData();
		}
		ss_error::log('Index render');
    	$smarty = $this->templates->create();
	    $smarty->assign('content', $content);
		$smarty->register_object('ss_path', $this->settings->server->appath);
	    $smarty->assign('context', $this);
    	return $smarty->fetch("staffList.tpl");
	}
}
?>